#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        string a;
        cin >> a;
        int len = a.size();
        if (len < 10)
        {
            cout << a << endl;
        }
        else
        {
            string b;
            b += a[0];
            b += to_string(len - 2);
            b += a[len - 1];
            cout << b << endl;
        }
    }
    return 0;
}